/*
 * button.cpp
 *
 *  Created on: Nov 4, 2008
 *      Author: cnsnyldz
 */

#include <GL/glut.h>
#include "button.h"
#include "draw.h"

using namespace std;

Button::Button(int lowX_,int lowY_,int highX_, int highY_, string text_, int textHighlight_)
				:lowX(lowX_),lowY(lowY_),highX(highX_),highY(highY_),text(text_),textHighlight(textHighlight_)
{
	setFg(0,0,0);
	setBg(1,1,1);
};

void Button::draw()
{
	glColor3f(bgr,bgg,bgb);
	Draw::FramedRectangle(lowX,lowY,highX,highY);
	glColor3f(fgr,fgg,fgb);
	Draw::Text(lowX+(highX-lowX)/4,lowY+(highY-lowY)/3,text,textHighlight,NORMAL);
}

bool Button::isClicked(int x, int y)
{
	if(x>lowX && x<highX && y>lowY && y<highY)
		return true;
	return false;
}

void Button::MouseOverHighlight()
{
	glColor3f(bgr,bgg,bgb);
	Draw::FramedRectangle(lowX-5,lowY+5,highX-5,highY+5);
	glColor3f(fgr,fgg,fgb);
	Draw::Text(lowX-5+(highX-lowX)/4,lowY+5+(highY-lowY)/3,text,textHighlight,NORMAL);
}
